UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'JSp1hxnQH8rM+AHySPve6IjBT53n7qD3y2tdvV1BLvk='
WHERE
key_id = 'aa9a16a6b5a9b2ab4a64f297d13622669d984149839129e6b575be435ae3fafe'
AND (
token = 'JSp1hxnQH8rM+AHySPve6IjBT53n7qD3y2tdvV1BLvk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)