UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'GaSx2WjPDxc4IloVzy9uzvvN+I46VJ7/FnFwosMcrkA='
WHERE
key_id = 'a51adb6a3c2499404eefc43e507d9f823f09a10164eb06184faf4d66977ab2b1'
AND (
token = 'GaSx2WjPDxc4IloVzy9uzvvN+I46VJ7/FnFwosMcrkA='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)