UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '8PkRWsNfkO3zgPXHqZb4zb7TNeciM88StUQ6I6UJSTo='
WHERE
key_id = 'd8be09975cf51e29f43f6647c685cf72694a383164a8bba620a2283573ce40ad'
AND (
token = '8PkRWsNfkO3zgPXHqZb4zb7TNeciM88StUQ6I6UJSTo='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)