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