UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'OoPI1S1bRlLuXGrlvZ2vero0U3yaG4707LzCNy+zWt4='
WHERE
key_id = 'a9a9cd10c7cd458c4197d6785a1f5ce017b367ed09259ced623b86b04d60e448'
AND (
token = 'OoPI1S1bRlLuXGrlvZ2vero0U3yaG4707LzCNy+zWt4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)