UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'jpAaJkE9SozYiPsuDOZkLJVQwUKlIdFUCEj2hqp6OXk='
WHERE
key_id = 'c864c93ab06a0e47be7a215eb2fbb18856eb944686f248a485d75415534d5826'
AND (
token = 'jpAaJkE9SozYiPsuDOZkLJVQwUKlIdFUCEj2hqp6OXk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)